
using System;
using PolObject = PolicyAlgebra.Type.Object;
using PolicyAlgebra.Type;
using PolicyAlgebra.Util;

namespace PolicyAlgebra
{
	public class PoolTool
	{
		public static void Main()
		{
			PolObject o11 = new PolObject("o11", "", "o11 comment");
			PolObject o12 = new PolObject("o11");
			PolObject o13 = new PolObject("o12");
			Set<PolObject> s1 = new Set<PolObject>();
			s1.AddMember(o11);
			s1.AddMember(o12);
			s1.AddMember(o13);

			PolObject o21 = new PolObject("o21");
			PolObject o22 = new PolObject("o21");
			PolObject o23 = new PolObject("o22");
			Set<PolObject> s2 = new Set<PolObject>();
			s2.AddMember(o21);
			s2.AddMember(o22);
			s2.AddMember(o23);

			PolObject o31 = new PolObject("o21");
			PolObject o32 = new PolObject("o21");
			PolObject o33 = new PolObject("o22");
			Set<PolObject> s3 = new Set<PolObject>();
			s3.AddMember(o31);
			s3.AddMember(o32);
			s3.AddMember(o33);

			Console.WriteLine(s1);
			Console.WriteLine(s2);

			Set<Set<PolObject>> pss = new Set<Set<PolObject>>();
			pss.AddMember(s1);
			pss.AddMember(s2);
			pss.AddMember(s3);

			Console.WriteLine(pss);


			Console.WriteLine("---------------------");

			Console.WriteLine("Testing primtive types:");

			PolObject o1 = new PolObject("object1");
			Console.WriteLine("Printing Object(object1): " + o1);

			Role r1 = new Role("role1", "role1 comment");
			Console.WriteLine("Printing Role(role1): " + r1);


			Console.WriteLine("---------------------");

			PermissionSet pset_1a = 
				new PermissionSet(new Allow("Read"), new Deny("Jump"));
			PermissionSet pset_1b = 
				new PermissionSet(new Allow("Read"), new Deny("Fly"));
			PermissionSetSet psetset_1 = new PermissionSetSet(pset_1a, pset_1b);
			Console.WriteLine("Test set 1:");
			Console.WriteLine(psetset_1);

			PermissionSet pset_2a = 
				new PermissionSet(new Allow("Read"), new Deny("Jump"));
			PermissionSet pset_2b = 
				new PermissionSet(new Allow("Read"), new Deny("Walk"));
			PermissionSetSet psetset_2 = new PermissionSetSet(pset_2a, pset_2b);
			Console.WriteLine("Test set 2:");
			Console.WriteLine(psetset_2);

			/////////////////////////////////
			// Inner conjunction.
			/////////////////////////////////
			Console.WriteLine("Doing inner conjunction:");
			PermissionSetSet psetsetconj = 
				PermissionSetSet.InnerConjunction(psetset_1, psetset_2);
			Console.WriteLine(psetsetconj);

			/////////////////////////////////
			// Inner disjunction.
			/////////////////////////////////
			Console.WriteLine("Doing inner disconjunction:");
			PermissionSetSet psetsetdisj = 
				PermissionSetSet.InnerDisjunction(psetset_1, psetset_2);
			Console.WriteLine(psetsetdisj);
		}
	}
}
